package com.henu.acmrating.common;

import lombok.Data;

@Data
public class Result {
    // 响应业务状态 1 成功 0 失败
    private Integer status;

    // 响应消息
    private String msg;

    // 响应中的数据
    private Object data;


    private Result(Object data) {
        this.status = 1;
        this.msg = "SUCCESS";
        this.data = data;
    }

    private Result(String msg) {
        this.status = 1;
        this.msg = msg;
        this.data = null;
    }

    private Result(Integer status, String msg, Object data) {
        this.status = status;
        this.msg = msg;
        this.data = data;
    }

    public static Result success() { return new Result(null); }

    public static Result success(String msg) { return new Result(msg); }

    public static Result success(Object data) {
        return new Result(data);
    }

    public static Result success(String msg, Object data) { return new Result(1, msg, data); }

    public static Result success(Integer status, String msg) { return new Result(status, msg, null); }

    public static Result success(Integer status, String msg, Object data) { return new Result(status, msg, data); }

    public static Result error() {
        return new Result(0, "ERROR", null);
    }

    public static Result error(String msg) {
        return new Result(0, msg, null);
    }
}